import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:sui_shou_pai/chat/entity/employee_model.dart';
import 'package:sui_shou_pai/module/color.dart';
import 'package:sui_shou_pai/module/effect.dart';

import 'chat_room.dart';

class EmployeeDetailPage extends StatefulWidget {
  final EmployeeModel employeeModel;

  EmployeeDetailPage({Key key, this.employeeModel}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return EmployeeDetailState();
  }
}

class EmployeeDetailState extends State<EmployeeDetailPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        elevation: 0,
      ),
      body: ListView(
        padding: EdgeInsets.all(16),
        children: [
          Container(
            margin: EdgeInsets.fromLTRB(6, 0, 6, 40),
            child: Row(
              children: [
                Container(
                  height: 80,
                  width: 80,
                  margin: EdgeInsets.only(left: 12),
                  child: ClipRRect(
                    borderRadius: borderRadiusAll8(),
                    child: Image.network(widget.employeeModel.avatar,
                        fit: BoxFit.cover),
                  ),
                ),
                Container(
                  height: 80,
                  margin: EdgeInsets.only(left: 20),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        widget.employeeModel.name,
                        style: TextStyle(
                            fontSize: 26, fontWeight: FontWeight.bold),
                      ),
                      Container(
                        margin: EdgeInsets.only(top: 4),
                        child: Text(
                          "员工号：" + widget.employeeModel.employeeId,
                          style: TextStyle(fontSize: 16, color: Colors.grey),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.symmetric(vertical: 10, horizontal: 16),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  child: Text("成员信息",
                      style:
                          TextStyle(fontSize: 19, fontWeight: FontWeight.bold)),
                ),
                SizedBox(height: 15),
                Container(
                  height: 55,
                  margin: EdgeInsets.only(bottom: 7),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text("部门",
                          style: TextStyle(fontSize: 15, color: Colors.grey)),
                      Text(widget.employeeModel.departmentName,
                          style: TextStyle(fontSize: 19))
                    ],
                  ),
                ),
                Divider(height: 5.0, color: greyF6F6F6, thickness: 1),
                Container(
                  height: 55,
                  margin: EdgeInsets.only(top: 7, bottom: 7),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text("职位",
                          style: TextStyle(fontSize: 15, color: Colors.grey)),
                      Text(widget.employeeModel.position,
                          style: TextStyle(fontSize: 19))
                    ],
                  ),
                ),
                Divider(height: 5.0, color: greyF6F6F6, thickness: 1),
                Container(
                  height: 55,
                  margin: EdgeInsets.only(top: 7, bottom: 7),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text("联系方式",
                          style: TextStyle(fontSize: 15, color: Colors.grey)),
                      Text(widget.employeeModel.phone,
                          style: TextStyle(fontSize: 19))
                    ],
                  ),
                ),
                Divider(height: 5.0, color: greyF6F6F6, thickness: 1),
              ],
            ),
          ),
          SizedBox(height: 30),
          GestureDetector(
            child: Container(
              height: 60,
              margin: EdgeInsets.all(16),
              decoration: BoxDecoration(
                color: Colors.blue,
                borderRadius: borderRadiusAll8(),
              ),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Icon(
                    Icons.messenger_outline_rounded,
                    color: Colors.white,
                  ),
                  Container(
                    margin: EdgeInsets.only(left: 10),
                    child: Text(
                      "发消息",
                      style: TextStyle(
                          fontSize: 19,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  )
                ],
              ),
            ),
            onTap: () {
              Fluttertoast.showToast(msg: "发消息");
              Navigator.push(
                  context,
                  new MaterialPageRoute(
                      builder: (context) => ChatRoom(
                          id: widget.employeeModel.id.toString(),
                          name: widget.employeeModel.name,
                          avatar: widget.employeeModel.avatar)));
            },
          ),
        ],
      ),
    );
  }
}
